package com.study.rabbit.mqtest;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class Consumer {
    @RabbitListener(queues = "TestDirectQueue")
    public void getMassage(String msg, Channel channel, Message message) throws IOException {
        System.out.println("消费者1接收到消息："+msg);

        //因为配置文件里开启了手动ack回执，所以不手动进行回执，该消息不会被消费，会分配给其他消费者或者当前消费者重新监听会再次获取该消息。

        //手动ack
//        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}

